package com.qf.service.impl;

import com.qf.mapper.DtsCategoryMapper;
import com.qf.service.CategoryService;
import com.qf.vo.CategorySellAmts;
import com.qf.vo.CategorySellVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/21 14:50
 */

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    DtsCategoryMapper dtsCategoryMapper;
    @Override
    public CategorySellVo selectCategory() {
         List<CategorySellAmts> categorySellData = dtsCategoryMapper.selectCategorySellAmts();
        List<String> categoryNames = categorySellData.stream().map(CategorySellAmts::getName).collect(Collectors.toList());
        CategorySellVo categorySellVo = new CategorySellVo();
        categorySellVo.setCategorySellData(categorySellData);
        categorySellVo.setCategoryNames(categoryNames);
        return categorySellVo;
    }
}
